Option Strict On
Option Explicit On 

Public Class UNext
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents cboTable As System.Windows.Forms.ComboBox
    Friend WithEvents lblTable As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(UNext))
        Me.cboTable = New System.Windows.Forms.ComboBox
        Me.lblTable = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'cboTable
        '
        Me.cboTable.AccessibleDescription = resources.GetString("cboTable.AccessibleDescription")
        Me.cboTable.AccessibleName = resources.GetString("cboTable.AccessibleName")
        Me.cboTable.Anchor = CType(resources.GetObject("cboTable.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.cboTable.BackgroundImage = CType(resources.GetObject("cboTable.BackgroundImage"), System.Drawing.Image)
        Me.cboTable.Dock = CType(resources.GetObject("cboTable.Dock"), System.Windows.Forms.DockStyle)
        Me.cboTable.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboTable.Enabled = CType(resources.GetObject("cboTable.Enabled"), Boolean)
        Me.cboTable.Font = CType(resources.GetObject("cboTable.Font"), System.Drawing.Font)
        Me.cboTable.ImeMode = CType(resources.GetObject("cboTable.ImeMode"), System.Windows.Forms.ImeMode)
        Me.cboTable.IntegralHeight = CType(resources.GetObject("cboTable.IntegralHeight"), Boolean)
        Me.cboTable.ItemHeight = CType(resources.GetObject("cboTable.ItemHeight"), Integer)
        Me.cboTable.Location = CType(resources.GetObject("cboTable.Location"), System.Drawing.Point)
        Me.cboTable.MaxDropDownItems = CType(resources.GetObject("cboTable.MaxDropDownItems"), Integer)
        Me.cboTable.MaxLength = CType(resources.GetObject("cboTable.MaxLength"), Integer)
        Me.cboTable.Name = "cboTable"
        Me.cboTable.RightToLeft = CType(resources.GetObject("cboTable.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.cboTable.Size = CType(resources.GetObject("cboTable.Size"), System.Drawing.Size)
        Me.cboTable.TabIndex = CType(resources.GetObject("cboTable.TabIndex"), Integer)
        Me.cboTable.Text = resources.GetString("cboTable.Text")
        Me.cboTable.Visible = CType(resources.GetObject("cboTable.Visible"), Boolean)
        '
        'lblTable
        '
        Me.lblTable.AccessibleDescription = resources.GetString("lblTable.AccessibleDescription")
        Me.lblTable.AccessibleName = resources.GetString("lblTable.AccessibleName")
        Me.lblTable.Anchor = CType(resources.GetObject("lblTable.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.lblTable.AutoSize = CType(resources.GetObject("lblTable.AutoSize"), Boolean)
        Me.lblTable.Dock = CType(resources.GetObject("lblTable.Dock"), System.Windows.Forms.DockStyle)
        Me.lblTable.Enabled = CType(resources.GetObject("lblTable.Enabled"), Boolean)
        Me.lblTable.Font = CType(resources.GetObject("lblTable.Font"), System.Drawing.Font)
        Me.lblTable.Image = CType(resources.GetObject("lblTable.Image"), System.Drawing.Image)
        Me.lblTable.ImageAlign = CType(resources.GetObject("lblTable.ImageAlign"), System.Drawing.ContentAlignment)
        Me.lblTable.ImageIndex = CType(resources.GetObject("lblTable.ImageIndex"), Integer)
        Me.lblTable.ImeMode = CType(resources.GetObject("lblTable.ImeMode"), System.Windows.Forms.ImeMode)
        Me.lblTable.Location = CType(resources.GetObject("lblTable.Location"), System.Drawing.Point)
        Me.lblTable.Name = "lblTable"
        Me.lblTable.RightToLeft = CType(resources.GetObject("lblTable.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.lblTable.Size = CType(resources.GetObject("lblTable.Size"), System.Drawing.Size)
        Me.lblTable.TabIndex = CType(resources.GetObject("lblTable.TabIndex"), Integer)
        Me.lblTable.Text = resources.GetString("lblTable.Text")
        Me.lblTable.TextAlign = CType(resources.GetObject("lblTable.TextAlign"), System.Drawing.ContentAlignment)
        Me.lblTable.Visible = CType(resources.GetObject("lblTable.Visible"), Boolean)
        '
        'UNext
        '
        Me.AccessibleDescription = resources.GetString("$this.AccessibleDescription")
        Me.AccessibleName = resources.GetString("$this.AccessibleName")
        Me.AutoScroll = CType(resources.GetObject("$this.AutoScroll"), Boolean)
        Me.AutoScrollMargin = CType(resources.GetObject("$this.AutoScrollMargin"), System.Drawing.Size)
        Me.AutoScrollMinSize = CType(resources.GetObject("$this.AutoScrollMinSize"), System.Drawing.Size)
        Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
        Me.Controls.Add(Me.cboTable)
        Me.Controls.Add(Me.lblTable)
        Me.Enabled = CType(resources.GetObject("$this.Enabled"), Boolean)
        Me.Font = CType(resources.GetObject("$this.Font"), System.Drawing.Font)
        Me.ImeMode = CType(resources.GetObject("$this.ImeMode"), System.Windows.Forms.ImeMode)
        Me.Location = CType(resources.GetObject("$this.Location"), System.Drawing.Point)
        Me.Name = "UNext"
        Me.RightToLeft = CType(resources.GetObject("$this.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.Size = CType(resources.GetObject("$this.Size"), System.Drawing.Size)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Event ValueChanged As EventHandler

    Private Sub UNext_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler cboTable.SelectionChangeCommitted, AddressOf OnValueChanged
    End Sub

    Protected Sub OnValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RaiseEvent ValueChanged(Me, New EventArgs)
    End Sub

    Public Sub Prepare(ByVal section As Model10.Section)
        cboTable.Items.Clear()

        Dim tbl As Model10.Table
        For Each tbl In section.Table.Presentation.Tables
            If Not tbl Is section.Table Then
                cboTable.Items.Add(tbl)
            End If
        Next : tbl = Nothing
    End Sub

    Public Sub Read(ByVal [next] As Model10.Next)
        cboTable.SelectedItem = [next].Table
    End Sub
    Public Sub Write(ByVal [next] As Model10.Next)
        [next].Table = CType(cboTable.SelectedItem, Model10.Table)
    End Sub
End Class
